/**
 * @author:albert
 */

package com.bkbw.live.battle.business.skill;

import java.lang.reflect.Constructor;
import java.util.HashMap;

import com.bkbw.live.battle.business.skill.effect.DamageEffect;

public class EffectFactory {
	
	protected HashMap<String, Class> effectLib = new HashMap<String, Class>();
	protected static EffectFactory instance = new EffectFactory();

	public static EffectFactory getInstance()
	{
		return instance;
	}

	private EffectFactory ()
	{
		effectLib.put("DamageEffect", DamageEffect.class);
	}

	public EffectBase createEffect(String effectClass,
		HashMap<String, Object> param)
	{
		EffectBase effect;
		try {
			Class[] paramType = new Class[]{HashMap.class};
			//Constructor constructor = Class.forName(effectClass).getConstructor(paramType);
			Constructor constructor = effectLib.get(effectClass).getConstructor(paramType);
			effect = (EffectBase)constructor.newInstance(param);
			return effect;
		}
		catch (Exception e) {
			return null;
		}
	}
}
